"""
__author__ = '霍格沃兹测试开发学社'
__desc__ = '更多测试开发技术探讨，请访问：https://ceshiren.com/t/topic/15860'
"""
from selenium.webdriver.common.by import By

from contacts_deparment_po.page_object.base_page import BasePage
from contacts_deparment_po.utils.log_utils import logger


class HomePage(BasePage):

    __menu_contacts = (By.ID, "menu_contacts")
    __BTN_ADD = (By.LINK_TEXT, "添加成员")
    __DEPT_ADD_MENU = (By.XPATH, "//i[@class='member_colLeft_top_addBtn']")
    __DEPT_ADD = (By.XPATH, "//a[text()='添加部门']")

    def click_add_member(self):
        """2.通讯录页面，点击添加成员按钮"""
        # 点击通讯录菜单
        self.do_click(self.__menu_contacts)

        logger.info("点击添加成员按钮")
        self.do_find(self.__BTN_ADD).click()

        from contacts_deparment_po.page_object.add_member_page import AddMemberPage
        return AddMemberPage(self.driver)

    def click_add_dept(self):
        """2.通讯录页面，点击添加部门按钮"""
        # 点击通讯录菜单
        self.do_click(self.__menu_contacts)

        logger.info("点击添加部门按钮")
        # 点击+号,
        self.do_click(self.__DEPT_ADD_MENU)
        # 点击添加部门
        self.do_click(self.__DEPT_ADD)

        from contacts_deparment_po.page_object.add_member_page import AddMemberPage
        return AddMemberPage(self.driver)